<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>组合对话框</title>
        <#include "/pubHeadStyle.html">
        <script src="${ctx}/extends/jquery.min.js" type="text/javascript"></script>
    </head>
    <body>
<div class="ccpui-tablesize" style="padding:10px;">
    <table id="combinationDialog" lay-filter="combinationDialog"></table>
</div>
<script type="text/html" id="formDialogToolsBar">
    <div class="ccpui-enterSel">
        <div class="layui-btn-container">
            <a class="layui-btn layui-btn-sm" lay-event="query">
                <i class="layui-icon layui-icon-search"></i>
                <span>查询</span>
            </a>
            <a class="layui-btn layui-btn-sm" lay-event="add">
                <i class="layui-icon layui-icon-add-1"></i>
                <span>添加</span>
            </a>
            <a class="layui-btn layui-btn-sm" lay-event="reset">
                <i class="layui-icon layui-icon-refresh"></i>
                <span>重置</span>
            </a>
            <a class="layui-btn layui-btn-sm" href="${ctx}/form/formDialog/view/list">
                <i class="layui-icon layui-icon-return"></i>
                <span>返回</span>
            </a>
        </div>
        <form class="layui-form" action="" style="margin-top:10px" lay-filter="formDialog_query">
            <div class="table-top-filter">
                <div class="table-filter-alone">
                    <label class="layui-form-label" style="width: 132px;">名称 </label>
                    <input type="text" name="Q_name_SL" id="name" class="layui-input filter-value"
                           autocomplete="off" placeholder="名称"/>
                </div>
                <div class="table-filter-alone">
                    <label class="layui-form-label">别名 </label>
                    <input type="text" name="Q_alias_SL" id="alias" class="layui-input filter-value"
                           autocomplete="off" placeholder="别名"/>
                </div>
                <div class="table-filter-alone">
                    <label class="layui-form-label" style="width: 132px;">左边树对话框名 </label>
                    <input type="text" name="Q_treeDialogName_SL" id="treeName" class="layui-input filter-value"
                           autocomplete="off" placeholder="左边树对话框名"/>
                </div>
                <div class="table-filter-alone">
                    <label class="layui-form-label" style="width: 132px;">右边列对话框名 </label>
                    <input type="text" name="Q_listDialogName_SL" id="colName" class="layui-input filter-value"
                           autocomplete="off" placeholder="右边列对话框名"/>
                </div>
            </div>
        </form>
    </div>
</script>

<script type="text/html" id="manageBar">
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    <a class="layui-btn layui-btn-xs" lay-event="preview">预览</a>
</script>
<script>
    layui.config({
        base: serverPath.formPath + staticPath.formPath //静态资源所在路径
    }).extend({
        index: 'index' //主入口模块
    }).use(['index', 'setter', 'layer', 'commons', 'form', 'jquery', 'layer', 'common', 'table', 'totalFilter'], function () {
        var table = layui.table, layer = layui.layer, setter = layui.setter, commons = layui.commons, form = layui.form,
            common = layui.common, totalFilter = layui.totalFilter;
        common.tableSort("combinationDialog");
        var tableH = commons.tabHeight();
        //渲染表格
        table.render({
            elem: '#combinationDialog'
            , cellMinWidth: 80
            , title: '组合对话框表'
            , defaultToolbar: []
            , height: tableH
            , url: serverPath.formPath + setter.formLinkPath + 'formDialog/combinationDialog/list'
            , toolbar: '#formDialogToolsBar'
            , page: true
            , autoSort: false
            , cols: [[
                {type: 'checkbox', fixed: 'left'}
                , {field: 'name', title: '名称', sort: true, align: 'center'}
                , {field: 'alias', title: '别名', sort: true, align: 'center'}
                , {field: 'width', title: '宽度', sort: true, align: 'center'}
                , {field: 'height', title: '高度', sort: true, align: 'center'}
                , {field: 'treeDialogName', title: '左边树对话框名', sort: true, align: 'center'}
                , {field: 'listDialogName', title: '右边列对话框名', sort: true, align: 'center'}
                , {fixed: 'right', title: '管理', toolbar: '#manageBar', width: 200, align: 'center'}
            ]],
            done: function () {
                common.tableSelectCon('.ccpui-enterSel .layui-form input', 'a[lay-event=query]', '.ccpui-enterSel')
            }
        });
        totalFilter.init('combinationDialog');
        table.on('toolbar(combinationDialog)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            var data = checkStatus.data; //获取选中行数据
            switch (obj.event) {
                case 'delete':
                    if (data.length === 0) {
                        layer.alert('请选择记录!');
                    } else {
                        layer.confirm('确认删除吗？', {
                            btn: ['是', '否'] //按钮
                        }, function (index) {
                            layer.close(index);
                            var ids = [];
                            for (var i = 0; i < data.length; i++) {
                                ids.push(data[i].id);
                            }
                            var queryIds = ids.join(',');
                            var t_date = {"ids": queryIds};
                            $.ajax({
                                url: serverPath.formPath + setter.formLinkPath + "formDialog/combinationDialog/del",
                                data: t_date,
                                dataType: 'json',
                                success: function (data) {
                                    layer.alert(data.msg);
                                    //执行重载
                                    table.reload('combinationDialog', {
                                        page: {
                                            curr: 1
                                        }
                                    });
                                    totalFilter.init('combinationDialog');
                                }
                            });
                        });
                    }
                    break;
                case 'query':
                    common.tableConditionRender("combinationDialog", "formDialog_query", {where: {}}, false);
                    break;
                case 'add':
                    parent.layer.open({
                        type: 2,
                        title: "添加组合对话框",
                        shade: 0.3,
                        area: ['750px', '500px'],
                        content: serverPath.formPath + setter.formLinkPath + "formDialog/combinationDialog/view/addDialog"
                        , end: function () {
                            table.reload('combinationDialog', {
                                page: {
                                    curr: 1
                                }
                            });
                            totalFilter.init('combinationDialog');
                        }
                    });
                    break;
                case 'reset':
                    common.tableConditionRender("combinationDialog", "formDialog_query", {where: {}}, true);
                    break;
            }
        });
        //监听行工具事件
        table.on('tool(combinationDialog)', function (obj) {
            var data = obj.data;
            switch (obj.event) {
                case 'del':
                    layer.confirm('确认删除吗？', function (index) {
                        var selId = obj.data.id;
                        var t_date = {"ids": selId};
                        $.ajax({
                            url: serverPath.formPath + setter.formLinkPath + "formDialog/combinationDialog/del",
                            data: t_date,
                            dataType: 'json',
                            success: function (data) {
                                layer.alert(data.msg);
                                //执行重载
                                table.reload('combinationDialog', {
                                    page: {
                                        curr: 1
                                    }
                                });
                                totalFilter.init('combinationDialog');
                            }
                        });
                    });
                    break;
                case 'edit':
                    parent.layer.open({
                        type: 2,
                        title: "添加组合对话框",
                        shade: 0.3,
                        area: ['750px', '500px'],
                        content: serverPath.formPath + setter.formLinkPath + "formDialog/combinationDialog/view/addDialog?combinationId=" + data.id
                        , end: function () {
                            table.reload('combinationDialog', {
                                page: {
                                    curr: 1
                                }
                            });
                            totalFilter.init('combinationDialog');
                        }
                    });
                    break;
                case 'preview':
                    var previewWidth = data.width + "px";
                    var previewHeight = data.height + "px";
                    parent.layer.open({
                        type: 2,
                        title: data.name,
                        shade: 0.3,
                        area: [previewWidth, previewHeight],
                        content: serverPath.formPath + setter.formLinkPath + "formDialog/combinationDialog/view/preview?isOpenJsonData=true&combinationAlias=" + data.alias
                    });
                    break;
            }
        });
    });
</script>
    </body>
</html>
<link rel="stylesheet" href="${ctx}/css/font/iconfontie.css" media="all"/>
<link rel="stylesheet" href="${ctx}/iconfont/iconfont.css"/>